/**
 * 数据统计管理初始化
 */
var Count = {
    id: "PlatformCountTable",	//表格id
    seItem: null,		//选中的条目
    table: null,
    layerIndex: -1
};

/**
 * 初始化表格的列
 */
Count.initColumn = function () {
    return [
        {field: 'selectItem', radio: true},
        {title: '序号', field: 'orderNumber', align: 'center', valign: 'middle',sortable: true},
        {title: '简称', field: 'abbreviation', align: 'center', valign: 'middle', sortable: true},
        {title: '浏览量', field: 'visitCount', align: 'center', valign: 'middle', sortable: true},
        {title: '点击申请量', field: 'clickCount', align: 'center', valign: 'middle', sortable: true},  
    ];
};

/**
 * 查询表单提交参数对象
 * @returns {{}}
 */
Count.formParams = function() {
    var queryData = {};
    queryData['beginTime'] = $("#beginTime").val();
    queryData['endTime'] = $("#endTime").val();
    return queryData;
}
Count.search = function () {
    Count.table.refresh({query: Count.formParams()});
    $.ajax({
        type: "GET",
        url: Feng.ctxPath + '/dataCount/totalPlatform/',
        data:Count.formParams(),
        dataType: "json",
        success: function(data){
            $('#type1').empty();
            $("#type1").html(data);
        }
    });
};
Count.downLoadExcel = function () {
     var param= parseParam(Count.formParams());
    location.href=Feng.ctxPath +'/dataCount/downloadExcel?'+param;
};

var parseParam = function(param, key) {
    var paramStr = "";
    if (param instanceof String || param instanceof Number || param instanceof Boolean) {
        paramStr += "&" + key + "=" + param;
    } else {
        $.each(param, function(i) {
            var k = key == null ? i : key + (param instanceof Array ? "[" + i + "]" : "." + i);
            paramStr += '&' + parseParam(this, k);
        });
    }
    return paramStr.substr(1);
};


$(function () {
    var defaultColunms = Count.initColumn();
    var table = new BSTable(Count.id, "/dataCount/platformCount", defaultColunms);
    table.setPaginationType("server");
    table.setQueryParams(Count.formParams());
    Count.table = table.init();
    $.ajax({
        type: "GET",
        url: Feng.ctxPath + '/dataCount/totalPlatform/',
        data:Count.formParams(),
        dataType: "json",
        success: function(data){
        	  $('#type1').empty();
              $("#type1").html(data);
        }
    });
});

